package com.aiyige.model.tag;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by zhuyakun on 2018/1/19.
 */

public class Tag implements Parcelable {
    String id;
    String sourceId;
    String name;
    String groupType;
    String groupName;
    boolean userSelect;
    String subGroupType;
    String subGroupName;
    String creator;
    Long createTime;
    Long updateTime;
    String channel;

    public Tag() {
    }

    private Tag(Builder builder) {
        setId(builder.id);
        setSourceId(builder.sourceId);
        setName(builder.name);
        setGroupType(builder.groupType);
        setGroupName(builder.groupName);
        setUserSelect(builder.userSelect);
        setSubGroupType(builder.subGroupType);
        setSubGroupName(builder.subGroupName);
        setCreator(builder.creator);
        setCreateTime(builder.createTime);
        setUpdateTime(builder.updateTime);
        setChannel(builder.channel);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public String getSourceId() {
        return sourceId;
    }

    public void setSourceId(String sourceId) {
        this.sourceId = sourceId;
    }

    public boolean isUserSelect() {
        return userSelect;
    }

    public void setUserSelect(boolean userSelect) {
        this.userSelect = userSelect;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGroupType() {
        return groupType;
    }

    public void setGroupType(String groupType) {
        this.groupType = groupType;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getSubGroupType() {
        return subGroupType;
    }

    public void setSubGroupType(String subGroupType) {
        this.subGroupType = subGroupType;
    }

    public String getSubGroupName() {
        return subGroupName;
    }

    public void setSubGroupName(String subGroupName) {
        this.subGroupName = subGroupName;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public static final class Builder {
        private String id;
        private String sourceId;
        private String name;
        private String groupType;
        private String groupName;
        private boolean userSelect;
        private String subGroupType;
        private String subGroupName;
        private String creator;
        private Long createTime;
        private Long updateTime;
        private String channel;

        private Builder() {
            userSelect = false;
        }

        public Builder id(String val) {
            id = val;
            return this;
        }

        public Builder sourceId(String val) {
            sourceId = val;
            return this;
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public Builder groupType(String val) {
            groupType = val;
            return this;
        }

        public Builder groupName(String val) {
            groupName = val;
            return this;
        }

        public Builder userSelect(boolean val) {
            userSelect = val;
            return this;
        }

        public Builder subGroupType(String val) {
            subGroupType = val;
            return this;
        }

        public Builder subGroupName(String val) {
            subGroupName = val;
            return this;
        }

        public Builder creator(String val) {
            creator = val;
            return this;
        }

        public Builder createTime(Long val) {
            createTime = val;
            return this;
        }

        public Builder updateTime(Long val) {
            updateTime = val;
            return this;
        }

        public Builder channel(String val) {
            channel = val;
            return this;
        }

        public Tag build() {
            return new Tag(this);
        }
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.sourceId);
        dest.writeString(this.name);
        dest.writeString(this.groupType);
        dest.writeString(this.groupName);
        dest.writeByte(this.userSelect ? (byte) 1 : (byte) 0);
        dest.writeString(this.subGroupType);
        dest.writeString(this.subGroupName);
        dest.writeString(this.creator);
        dest.writeValue(this.createTime);
        dest.writeValue(this.updateTime);
        dest.writeString(this.channel);
    }

    protected Tag(Parcel in) {
        this.id = in.readString();
        this.sourceId = in.readString();
        this.name = in.readString();
        this.groupType = in.readString();
        this.groupName = in.readString();
        this.userSelect = in.readByte() != 0;
        this.subGroupType = in.readString();
        this.subGroupName = in.readString();
        this.creator = in.readString();
        this.createTime = (Long) in.readValue(Long.class.getClassLoader());
        this.updateTime = (Long) in.readValue(Long.class.getClassLoader());
        this.channel = in.readString();
    }

    public static final Creator<Tag> CREATOR = new Creator<Tag>() {
        @Override
        public Tag createFromParcel(Parcel source) {
            return new Tag(source);
        }

        @Override
        public Tag[] newArray(int size) {
            return new Tag[size];
        }
    };
}
